package com.emperor.employee.logic;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.emperor.core.logic.BizModelBase;
import com.emperor.util.DateFormatter;

public class EmployeeModel extends BizModelBase implements Employee {

	private Long id;
	private String code;
	private Long codeid;
	private String name;
	private String ic;
	private Date birthdate;
	private String phone;
	private String email;
	private String address;
	private String status;
	
	private SimpleDateFormat sdf = new SimpleDateFormat(DateFormatter.YYYYMMDD);
	
	public Long getId() {
		return id;
	}

	public void setId(Object id) {
		if (id != null) {
			if (id instanceof Long) {
				this.id = (Long) id;
			} else {
				try {
					this.id = new Long(id.toString());
				} catch (Exception e) {
				}
			}
		}
	}

	public String getName() {
		return name;
	}

	public void setName(Object name) {
		if (name != null) {
			if (name instanceof String) {
				this.name = (String) name;
			} else {
				try {
					this.name = name.toString();
				} catch (Exception e) {
				}
			}
		}
	}

	public String getIc() {
		return ic;
	}

	public void setIc(Object ic) {
		if (ic != null) {
			if (ic instanceof String) {
				this.ic = (String) ic;
			} else {
				try {
					this.ic = ic.toString();
				} catch (Exception e) {
				}
			}
		}
	}

	public Date getBirthdate() {
		return birthdate;
	}

	public void setBirthdate(Object birthdate) {
		if (birthdate != null) {
			if (birthdate instanceof Date) {
				this.birthdate = (Date) birthdate;
			} else {
				try {
					this.birthdate = sdf.parse(birthdate.toString());
				} catch (Exception e) {
				}
			}
		}
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(Object phone) {
		if (phone != null) {
			if (phone instanceof String) {
				this.phone = (String) phone;
			} else {
				try {
					this.phone = phone.toString();
				} catch (Exception e) {
				}
			}
		}
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(Object email) {
		if (email != null) {
			if (email instanceof String) {
				this.email = (String) email;
			} else {
				try {
					this.email = email.toString();
				} catch (Exception e) {
				}
			}
		}
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(Object address) {
		if (address != null) {
			if (address instanceof String) {
				this.address = (String) address;
			} else {
				try {
					this.address = address.toString();
				} catch (Exception e) {
				}
			}
		}
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(Object status) {
		if (status != null) {
			if (status instanceof String) {
				this.status = (String) status;
			} else {
				try {
					this.status = status.toString();
				} catch (Exception e) {
				}
			}
		}
	}

	public String getCode() {
		return code;
	}

	public void setCode(Object code) {
		if (code != null) {
			if (code instanceof String) {
				this.code = (String) code;
			} else {
				try {
					this.code = code.toString();
				} catch (Exception e) {
				}
			}
		}
	}

	public List<String> getFieldNames() {
		List<String> fieldNames = new ArrayList<String>();
		
		fieldNames.add(FLD_ID);
		fieldNames.add(FLD_NAME);
		fieldNames.add(FLD_CODE);
		fieldNames.add(FLD_CODEID);
		fieldNames.add(FLD_IC);
		fieldNames.add(FLD_BIRTHDATE);
		fieldNames.add(FLD_PHONE);
		fieldNames.add(FLD_EMAIL);
		fieldNames.add(FLD_ADDRESS);
		fieldNames.add(FLD_STATUS);
		
		fieldNames.add(FLD_CRTBY);
		fieldNames.add(FLD_CRTDATE);
		fieldNames.add(FLD_UPDBY);		
		fieldNames.add(FLD_UPDDATE);
		
		return fieldNames;
	}

	public Long getCodeid() {
		return codeid;
	}

	public void setCodeid(Object codeid) {
		if (codeid != null) {
			if (codeid instanceof Long) {
				this.codeid = (Long) codeid;
			} else {
				try {
					this.codeid = new Long(codeid.toString());
				} catch (Exception e) {
				}
			}
		}
	}

}
